package iBuyCoolSky.ui.BuyMeUI;
import iBuyCoolSky.obsevers.Sensor;

import java.awt.*;
import java.util.Observable;
import java.util.Observer;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JLabel;

import dataClass.Product;

public class ImagePanelBM extends JPanel implements Observer{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public JLabel image_label;
	public ImagePanelBM(String path)
	{
		this.setPreferredSize(new Dimension(260,180));
		System.out.println("path :" + path);
		if(path.isEmpty() == false)
			image_label=new JLabel(new ImageIcon(path));
		else
			image_label = new JLabel(new ImageIcon("picture/fail.jpg"));
		add(image_label);
	}
	public void update(Observable subject, Object obj)
	{
		String path = ((Product)((Sensor)subject).getData()).img_Location;
		System.out.println("newPath" + path);
		if(path.isEmpty()==false)
			{
				image_label.setIcon(new ImageIcon(path));
			}
		else
			image_label.setIcon(new ImageIcon("picture/fail.jpg"));
	}
}
